//https://www.hackerrank.com/challenges/lisa-workbook#include <cmath>#include <cstdio>#include <vector>#include <iostream>#include <algorithm>using namespace std;int main() {        int n,k;    cin >> n >> k;    int holder[n];        for(int i = 0 ; i < n ; ++i){        cin >> holder[i];    }    int count = 0;    int pages[1001][1001];    int j = 1;    bool ok = false;    for(int i = 0 ; i < n ; ++i){        int a = 1;                int f = 1;        int ct = holder[i];        while(ct--){            ok = true;            pages[j][f] = a++;            // cout << j << " - page / f - " << f << " a - " << a-1 << endl;            if(j == a-1)count++;            if(f == k){                j++;                f = 0;                ok = false;            }            f++;        }        if(ok)j++;    }        cout << count;        return 0;}